package org.springblade.modules.admin.entity.es;

import lombok.Data;
import lombok.experimental.Accessors;
import org.dromara.easyes.annotation.HighLight;
import org.dromara.easyes.annotation.IndexField;
import org.dromara.easyes.annotation.IndexId;
import org.dromara.easyes.annotation.IndexName;
import org.dromara.easyes.annotation.rely.FieldType;
import org.dromara.easyes.annotation.rely.IdType;


/**
 * 手动维护自定义分词器
 PUT /test_parts_document
 {
 "settings": {
 "analysis": {
 "analyzer": {
 "ik_smart_pinyin": {
 "type": "custom",
 "tokenizer": "ik_smart",
 "filter": ["my_pinyin", "word_delimiter"]
 },
 "ik_max_word_pinyin": {
 "type": "custom",
 "tokenizer": "ik_max_word",
 "filter": ["my_pinyin", "word_delimiter"]
 },
 "custom_synonyms": {
 "type": "custom",
 "tokenizer": "ik_smart",
 "filter": ["my_synonym", "word_delimiter"]
 }
 },
 "filter": {
 "my_pinyin": {
 "type" : "pinyin",
 "keep_separate_first_letter" : true,
 "keep_full_pinyin" : true,
 "keep_original" : true,
 "limit_first_letter_length" : 16,
 "lowercase" : true,
 "remove_duplicated_term" : true
 },
 "my_synonym": {
 "type": "synonym",
 "updateable": true,
 "synonyms_path": "analysis/synonyms.txt"
 }
 }
 }
 }
 }


 POST /test_parts_document/_mapping
 {
 "properties": {
 "name": {
 "type": "text",
 "analyzer": "ik_max_word_pinyin",
 "search_analyzer": "ik_smart_pinyin"
 },
 "ancestors": {
 "type": "keyword"
 },
 "nameSynonyms": {
 "type": "text",
 "analyzer": "ik_smart",
 "search_analyzer": "custom_synonyms"
 }
 }
 }
 */


@Data
@Accessors(chain = true)
@IndexName(value = "parts_document", shardsNum = 3, replicasNum = 0, keepGlobalPrefix = true, maxResultWindow = 100)
public class PartsDocument {

	@IndexId(type = IdType.CUSTOMIZE)
	private Long id;

	//	@MultiIndexField(mainIndexField = @IndexField(fieldType = FieldType.KEYWORD_TEXT),
//		otherIndexFields = {@InnerIndexField(suffix = "zh", fieldType = FieldType.TEXT, analyzer = Analyzer.IK_MAX_WORD, searchAnalyzer = Analyzer.IK_SMART),
//			@InnerIndexField(suffix = "pinyin", fieldType = FieldType.TEXT, analyzer = Analyzer.PINYIN)})
	@HighLight(mappingField = "highlightContent")
	@IndexField(fieldType = FieldType.TEXT, analyzer = "ik_max_word", searchAnalyzer = "custom_ik_smart")
	private String name;
	@IndexField(fieldType = FieldType.TEXT, analyzer = "ik_smart", searchAnalyzer = "custom_synonyms")
	private String nameSynonyms;
	@IndexField(fieldType = FieldType.TEXT, analyzer = "ik_max_word", searchAnalyzer = "custom_pinyin")
	private String namePinyin;

	private String ancestors;

	private String highlightContent;


}
